username = 'admin'
password = '1234'


def function(func):
    def fun():
        user = input(f"请输入账号")
        pw = input(f"请输入密码")
        print(user)
        print(pw)

        if user == username and pw == password:
            print(func)
        else:
            print("账号密码不正确")

    return fun


# def func():
#     pass
#
# @func
# def login_error():
#     pass

@function # 等效 login = function(login)
def login():
    print("登录成功")

login = function(12)

#__closure__取出存储在当前属性的return对象
# obj = login()
print(login.__closure__)


a1=100

def add(a1):
    return 99

res = add(a1)
print(res)

def decorator(function):
    def closure():
        print(f"这是闭包")
        function()
        print(f"这是结束闭包")
    return closure


@decorator
def greet():
    print(f"这是被装饰的函数")

greet()

print(greet.__closure__)